package de.clapp.musicbox.loader;

import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import de.clapp.CLAppModel;
import de.clapp.Settings;
import de.clapp.backend.network.ClientRequest;
import de.clapp.backend.network.TCPSocket;
import de.clapp.backend.requests.MusicVoteRequest;
import de.clapp.data.Club;
import de.clapp.data.MusicItem;

public class MusicVoteRequestLoader extends AsyncTaskLoader<Object>
{
    private MusicItem item;
    
    public MusicVoteRequestLoader(Context context, MusicItem item)
    {
        super(context);
        this.item = item;
    }

    @Override
    public Object loadInBackground()
    {
        MusicVoteRequest request = new MusicVoteRequest(this.item);

        try
        {
            Club club = CLAppModel.getInstance().getCurrentClub();
            ClientRequest cr = new ClientRequest(new TCPSocket(club.getIpAddress(), club.getPort()));
            cr.request(request);
            request.getItem();
//            cr.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return new Object();
    }
}
